import { IPSRawItemBase } from '../ipsraw-item-base';
import { IPSRawItemContainer } from '../ipsraw-item-container';
import { IPSDECMRawItem } from './ipsdecmraw-item';
import { IPSDETBRawItem } from './ipsdetbraw-item';
import { PSDEToolbarItemImpl } from './psdetoolbar-item-impl';

export class PSDETBRawItemImpl extends PSDEToolbarItemImpl implements IPSDETBRawItem, IPSDECMRawItem, IPSRawItemContainer {
  get contentType(): string {
    return this.M.contentType;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get htmlContent(): string {
    return this.M.htmlContent;
  }

  protected psrawitem: IPSRawItemBase | null = null;

  getPSRawItem(): IPSRawItemBase | null {
    if (this.psrawitem != null) return this.psrawitem;
    const value = this.M.getPSRawItem;
    if (value == null) {
      return null;
    }
    this.psrawitem = this.getPSModel4('control.IPSRawItemBase', value, 'getPSRawItem') as IPSRawItemBase;
    return this.psrawitem;
  }

  get psRawItem(): IPSRawItemBase | null {
    return this.getPSRawItem();
  }

  getPSRawItemMust(): IPSRawItemBase {
    const value = this.getPSRawItem();
    if (value == null) {
      throw new Error('未指定直接内容对象');
    }
    return value;
  }

  get rawContent(): string {
    return this.M.rawContent;
  }

  get rawItemHeight(): number {
    return this.M.rawItemHeight != null ? this.M.rawItemHeight : 0.0;
  }

  get rawItemWidth(): number {
    return this.M.rawItemWidth != null ? this.M.rawItemWidth : 0.0;
  }

  get tooltip(): string {
    return this.M.tooltip;
  }

  get showIcon(): boolean {
    return this.M.showIcon;
  }

  get cls(): string {
    return 'PSDETBRawItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSRawItem' || cls == 'control.IPSRawItemContainer' || cls == 'control.toolbar.IPSDECMRawItem' || cls == 'control.toolbar.IPSDETBRawItem') return true;
    return super.instanceof(cls);
  }
}
